<?php

class Application_Form_Book extends Zend_Form {

    public function init() {
        $this->setName('book');
        $id = new Zend_Form_Element_Hidden('id');
        $id->addFilter('Int');
        $author = new Zend_Form_Element_Text('author');
        $author->setLabel('Author')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Title')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');


        $file = new Zend_Form_Element_File('image');
        $file->setLabel('Image')
                //->setRequired(true)
                ->setDestination(realpath(APPLICATION_PATH . '/../public/PictureBook/'))
                // ensure only 1 file
                ->addValidator('Count', false, 1)
                // limit to 100K
                ->addValidator('Size', false, 102400)
                // only JPEG, PNG, and GIFs
                ->addValidator('Extension', false, 'jpg,png,gif');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton');

        $this->addElements(array($id, $author, $title, $file, $submit));
    }

}
